package com.gxa.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.vo.R;
import com.gxa.modules.mapper.PayableByCarrierMapper;
import com.gxa.modules.pojo.PayableByCarrier;
import com.gxa.modules.service.PayableByCarrierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Service
public class PayableByCarrierServiceImpl extends ServiceImpl<PayableByCarrierMapper, PayableByCarrier> implements PayableByCarrierService {

    @Autowired
    private PayableByCarrierMapper payableByCarrierMapper;

    @Override
    public R findbyid(Integer carrierId) {
        R r=new R();
        r.setCode(200);
        r.setMsg("suceess");
        PayableByCarrier payableByCarrier = payableByCarrierMapper.findbyid(carrierId);
        Integer errStatus = payableByCarrier.getErrStatus();
        if(errStatus==2){
            payableByCarrier.setErrStatus(1);
        }else {
            payableByCarrier.setErrStatus(2);
        }

        r.setData(payableByCarrier);

        return r;
    }

    @Override
    public R selectcoditions(Date createTime, Integer carrierId) {
        R r=new R();
        r.setCode(200);
        r.setMsg("suceess");
        List<PayableByCarrier> selectcoditions = payableByCarrierMapper.selectcoditions(createTime, carrierId);
        r.setData(selectcoditions);

        return r;
    }

}
